package com.study.springbootsecurity.consumer;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;

import java.util.List;

/**
 * @Description: TODO
 * @author: Huangjianyun 二维码kafka消费者
 * @date: 2025-06-21 15:38
 */
@Slf4j
public class QrCodeListenerConsumer {

    @KafkaListener(topics = "${springboot3.kafka.qrcode.topic}")
    public void lister(List<ConsumerRecord> consumerRecords, Acknowledgment ack) {
        try {
            for (ConsumerRecord record : consumerRecords) {
                log.info("流水线消费"+record.toString());
            }
        }catch (Exception e) {
            log.error("流水线消费发生异常"+e.getMessage());
        }finally {
            // 手动提交消息偏移量
            ack.acknowledge();
        }
    }
}
